﻿Imports System.ServiceModel
Imports System.Runtime.Serialization
Namespace DataContract
    <DataContract>
    Public Class ManagePSCFault
        <DataMember>
        Public ErrorMessage As String
        Public ErrorMethod As String
        Public Exception As Exception

        Public Shared Function GenerateFault(ErrorMessage As String, Optional theException As Exception = Nothing) As FaultException(Of ManagePSCFault)
            Dim theFault As New ManagePSCFault

            With theFault
                .ErrorMessage = ErrorMessage
                .ErrorMethod = New StackFrame(1).GetMethod.ReflectedType.Name
                .Exception = theException
            End With

            Return New FaultException(Of ManagePSCFault)(theFault, ErrorMessage)
        End Function
    End Class
End Namespace